import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/education/couser_center/textbook_list_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/education/train_plan/get_education_plan_entity.dart';

///培训课程
class TrainCourseController extends GetxController {
  /// 筛选右侧栏控制Key
  final riskRightScaffoldKey = GlobalKey<ScaffoldState>();

  /// 列表刷新key
  final GlobalKey<CustomEasyRefreshListState> globalKey = GlobalKey();

  /// 搜索条件
  String? searchX;

  /// 请求参数
  Map<String, dynamic> queryParameters = {};

  ///获取相应数据
  GetEducationPlanEntity? data;

  /// 获取数据 查询改计划下的课程列表
  Future<List<TextbookListEntity>> textbookList(int index, int size, {String? search}) async {
    final res = await HttpUtil().generateGetRequest<List<TextbookListEntity>>(
      Interface.getTextBookByPlanId,
      queryParameters: {
        'pageNum': index,
        'pageSize': size,
        'id': Get.arguments['id'], //外面的列表id
        'bookName': searchX, //模糊查询 课程名字
      },
    ).execute();
    List<TextbookListEntity>? list = [];
    res.onSuccess((result) {
      if (result.data != null) {
        list = result.data;
      }
    });
    return list!;
  }
  void refreshPage() {
    globalKey.currentState?.onRefresh();
  }
}
